/**
 * Created by think on 2017/1/1.
 */
var fs = require("fs");

/**获取当前工程的根目录，常量_dirname */
var path = __dirname;
//fs.readFile(path + '/data.js',"utf8", (err, data) => {
//    if (err) throw err;
//    console.log(data);
//});


fs.readFile(path + '/data.js', (err, data) => {
    if (err) throw err;
    console.log(data.toString("utf8", 0, data.length));

    fs.writeFile(path + '/data_bak.js', data, (err)=>{
        if(err) {
            console.log("err:"+err);
            throw err;
        }

        console.log("success");
    });
});